
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>

#include <LengthUnit.h>
#include <Quantity.h>

#include <InchFormat.h>
#include <WholeFormat.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

typedef Quantity<LengthUnit> Length;

FIXTURE(LengthUnit)
{

	TEST(should be able to compare feets with yards, equal condition )
        {
		Length length_1(3, FEET);
		Length length_2(1, YARD);
		ASSERT_EQ(1, length_1==length_2);
	}

        TEST(should be able to compare feets with inchs, equal condition )
        {
		Length length_1(1, FEET);
		Length length_2(12, INCH);
		ASSERT_EQ(1, length_1==length_2);
	}

	TEST(should be able to compare feets with miles, equal condition )
        {
		Length length_1(5280, FEET);
		Length length_2(1, MILE);
		ASSERT_EQ(1, length_1==length_2);
	}

        TEST(should be able to compare yards with inchs, equal condition )
        {
		Length length_1(1, YARD);
		Length length_2(36, INCH);
		ASSERT_EQ(1, length_1==length_2);
	}

	TEST(should be able to compare yards with miles, equal condition )
        {
		Length length_1(1760, YARD);
		Length length_2(1, MILE);
		ASSERT_EQ(1, length_1==length_2);
	}

	TEST(should be able to compare inchs with miles, equal condition )
        {
		Length length_1(63360, INCH);
		Length length_2(1, MILE);
		ASSERT_EQ(1, length_1==length_2);
	}

	TEST(should be able to do addition between inchs and feets)
	{
		ASSERT_TRUE(Length(3,FEET) == (Length(12, INCH)+Length(2, FEET)));
	}

	TEST(should be able to output string with requirement whole format: 2 FEET 11 INCH)
	{
		Length length(35,INCH);
                ostringstream sio;
		WholeFormat wholeFormat;
                length.formatOutput(sio,wholeFormat);
		ASSERT_EQ(sio.str(), string("2 FEET 11 INCH"));
	}

	TEST(should be able to output string with requirement whole format: 1 YARD 2 INCH)
	{
		Length length(38,INCH);
                ostringstream sio;
		WholeFormat wholeFormat;
                length.formatOutput(sio,wholeFormat);
		ASSERT_EQ(sio.str(), string("1 YARD 2 INCH"));
	}

	TEST(should be able to output string with requirement whole format: 1 MILE 21 YARD)
	{
		Length length(1781,YARD);
                ostringstream sio;
		WholeFormat wholeFormat;
                length.formatOutput(sio,wholeFormat);
		ASSERT_EQ(sio.str(), string("1 MILE 21 YARD"));
	}

	TEST(should be able to output string with requirement inch format:63360 INCH)
	{
		Length length(1,MILE);
                ostringstream sio;
		InchFormat inchFormat;
                length.formatOutput(sio,inchFormat);
		ASSERT_EQ(sio.str(), string("63360 INCH"));
	}

	TEST(should be able to output string with requirement inch format:36 INCH)
	{
		Length length(1,YARD);
                ostringstream sio;
		InchFormat inchFormat;
                length.formatOutput(sio,inchFormat);
		ASSERT_EQ(sio.str(), string("36 INCH"));
	}

	TEST(should be able to output string with requirement inch format:12 INCH)
	{
		Length length(1,FEET);
                ostringstream sio;
		InchFormat inchFormat;
                length.formatOutput(sio,inchFormat);
		ASSERT_EQ(sio.str(), string("12 INCH"));
	}

	TEST(should be able to output string with requirement inch format:1 INCH)
	{
		Length length(1,INCH);
                ostringstream sio;
		InchFormat inchFormat;
                length.formatOutput(sio,inchFormat);
		ASSERT_EQ(sio.str(), string("1 INCH"));
	}


};
